window.onload = function () {
    getTodayDeliveryList()
}

//getTodayDeliveryList 获取当日送货清单
function getTodayDeliveryList() {
    let nowDate = $(".main-warp").data("date")
    $.post("/todayDeliveryList", {
        nowDate: "2021-06-11",
    }, function (res, status) {
        console.log(res)
        if (res.data.todayDeliveryList === null) {
            alert("当天没有送货信息")
            return
        }
        let deliveryTable = document.getElementsByClassName("delivery-warp")
        deliveryTable[0].innerHTML = '' +
            '<thead><tr>' +
            '<th scope="col">商品号</th>' +
            '<th scope="col">商品名</th>' +
            '<th scope="col">所需商品数量</th>' +
            '<th scope="col">所需金额</th>' +
            '<th scope="col">代销处名</th>' +
            '<th scope="col">代销处地址</th>' +
            '<th scope="col">代销处电话</th>' +
            '</tr></thead>';
        deliveryTable[0].innerHTML += addDeliveryListToHTML(res.data.todayDeliveryList);
    })
}

//addDeliveryListToHTML 添加送货清单信息
function addDeliveryListToHTML(todayDeliveryList) {
    let s = '<tbody>'
    for (let i = 0; i < todayDeliveryList.length; ++i) {
        s += '' +
            '<tr>' +
            '<td>' + todayDeliveryList[i].GoodNo + '</td>' +
            '<td>' + todayDeliveryList[i].GoodName.String + '</td>' +
            '<td>' + todayDeliveryList[i].GoodNum + '</td>' +
            '<td>' + todayDeliveryList[i].GoodTotalPrice + '</td>' +
            '<td>' + todayDeliveryList[i].ConsignmentName.String + '</td>' +
            '<td>' + todayDeliveryList[i].ConsignmentAdr.String + '</td>' +
            '<td>' + todayDeliveryList[i].ConsignmentTel.String + '</td>' +
            '</tr>';
    }
    s += '</tbody>';
    return s;
}